from graph import graph
graph.get_graph().print_ascii()
# print(graph.get_graph().draw_mermaid())

def do_stream(user_input):
    resps = graph.stream({"messages": [("user", user_input)]}, stream_mode="values")
    last = None
    for value in resps:
        message = value["messages"][-1]
        # message.pretty_print()
        last = message.content
    print('AI: ', last)

while True:
    try:
        user_input = input("User: ")
        if user_input.lower() in ["quit", "exit", "q"]:
            print("Goodbye!")
            break
        
        do_stream(user_input)
    except Exception as e:
        print("Error: input() is not available: ", e)
        break